package SIM_cgiSettings;
require Exporter;

use SIM_settings;
use strict;

# Settings module for shared perl settings.
our @ISA        = ("Exporter");
our @EXPORT     = qw(
		     %ipColor %dnsColor %macColor %manColor %manAbrev %recColor %recAbrev %recFontColor %intStatusColor
                     %typeColor %typeDescr
                    );
our @VERSION    = 0.01;                 # version number

our %ipColor = ();
our %nodeStatusColor = ();
our %dnsColor;
our %macColor;
our %intStatusColor;
our ( %manColor, %manAbrev );
our ( %recColor, %recAbrev, %recFontColor );
open(INFO, "$SIMparam{'SIMreccordTypes'}") || die "Oops, could not open SIMreccordTypes.";
my @lines = <INFO>;
close(INFO);
foreach my $regel (@lines) {
  chomp $regel;
  my ( $type, $var1, $var2, $var3, $var4 ) = split(' ', $regel);
  if ( $type eq "ipColor" ) {
    $ipColor{$var1} = $var2;
  } elsif ( $type eq "nodeStatusColor" ) {
    $nodeStatusColor{$var1} = $var2;
  } elsif ( $type eq "dnsColor" ) {
    $dnsColor{$var1} = $var2;
  } elsif ( $type eq "macColor" ) {
    $macColor{$var1} = $var2;
  } elsif ( $type eq "manInfo" ) {
    $manColor{$var1} = $var2;
    $manAbrev{$var1} = $var3;
  } elsif ( $type eq "recInfo" ) {
    $recColor{$var1} = $var2;
    $recAbrev{$var1} = $var3;
    $recFontColor{$var1} = $var4;
  } elsif ( $type eq "intStatusColor" ) {
    $intStatusColor{$var1} = $var2;
  }
}
our ( %typeColor, %typeDescr );
open(INFO, "$sharedConfDir/nodeTypes");
my @lines = <INFO>;
close(INFO);
foreach my $regel (@lines) {
  chomp $regel;
  my ( $prefix, $type, $color, $default, $pollType, $dnsType, $description ) = split(' ', $regel, 7);
  if ( $prefix eq "nodeType" ) {
    $typeColor{$type} = $color;
    $typeDescr{$type} = $description;
  }
}

1;

